#ifndef _VISIONECONTROLLER_
#define _VISIONECONTROLLER_

#include <libfreenect.hpp>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <pthread.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
#include "RiconoscimentoPalla.h"
#include "RiconoscimentoPorta.h"
#include "MyFreenectDevice.h"
#include "Filtro.h"

using namespace cv;
using namespace std;
#define MIN_AREA_PORTA 20000
#define MIN_AREA_OSTACOLO 20000

using namespace std;

class VisioneController{

private:
	pthread_t thread1;
	Mat rgbMatTmp,rgbMat,depthMatTmp,depthMat;
	Mat* hsvMat;
	Scalar infPalla,supPalla;
	Mat img_palla_filt,img_palla_filt2,img_porta_filt,img_porta_filt2;
	RotatedRect * maxRettangoloPalla;
	Rect maxRettangoloPorta;
	//Dichiarazione variabili porta
	Scalar infPorta, supPorta;

	RiconoscimentoPorta *porta;
	RiconoscimentoPalla *palla;
	unsigned short profPorta,profPalla;
	double angoloPorta,angoloPalla;
	Point centroPorta,centroPalla;

	//OSTACOLO

	IplImage *img;
	IplImage* rettangoloRoi;

	Filtro *filtro;
	Freenect::Freenect freenect;
	MyFreenectDevice *device;
public:
	VisioneController();
	~VisioneController();
	void elaborateImage();
	unsigned short getProfonditaPorta();
	int getAngoloPorta();
	unsigned short getProfonditaPalla();
	int getAngoloPalla();
	void abbassa();
	void alza();
	void azzera();
};

#endif
